package com.vhall.component.service.goods.assembler;

import com.vhall.component.entity.goods.GoodsEntity;
import com.vhall.component.entity.goods.goods.GoodsRspVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * 商品类实体对象间转换
 *
 * @author yuanzh
 * @date 2021/10/26
 */
@Mapper(componentModel = "spring")
public interface GoodsAssembler {

    /**
     * 商品实体对象转换为响应对象
     *
     * @param entity 商品实体对象
     * @return 响应对象
     */
    @Mapping(source = "createdAt", target = "createdAt", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(source = "updatedAt", target = "updatedAt", dateFormat = "yyyy-MM-dd HH:mm:ss")
    GoodsRspVO goodsEntityToRspVo(GoodsEntity entity);

    /**
     * 商品实体列表转换为响应列表
     *
     * @param entities 商品列表
     * @return 响应列表
     */
    List<GoodsRspVO> goodsEntitiesToRspVos(List<GoodsEntity> entities);

}
